package com.ioandfile;

import org.apache.commons.io.IOUtils;

import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class ShenfenZheng {
    public static void main(String[] args) {
        InputStream is = null;
        InputStreamReader isr = null;
        BufferedReader br = null;
        Map<String,String> map = new HashMap<>();


        try {
            is = new FileInputStream("/Users/edy/Desktop/file/身份证所在地.csv");
            isr = new InputStreamReader(is);
            br = new BufferedReader(isr);

            String str;
            while ((str = br.readLine()) != null) {
                String[] split = str.split(",");
                map.put(split[0],split[1]);
            }

            Scanner scanner = new Scanner(System.in);
            System.out.println("输入身份证前六位");
            String numb = scanner.nextLine();
            for (Map.Entry<String, String> entry : map.entrySet()) {
                if (entry.getKey().equals(numb)) {
                    System.out.println("对应的地区为" + entry.getValue());
                }
            }


        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            IOUtils.closeQuietly(br);
            IOUtils.closeQuietly(isr);
            IOUtils.closeQuietly(is);
        }
    }
}
